package com.zhou.kotlin_car_data_list.adapter

import android.text.TextUtils
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.squareup.picasso.Picasso
import com.zhou.kotlin_car_data_list.R

/**
 * </br>
 * Date: 2025/8/24
 * Created by:zhourui
 */
object ImageViewBindingAdapter {

    @BindingAdapter("itemImage")
    @JvmStatic
    fun setImage(iv: ImageView, url: String) {
        if (TextUtils.isEmpty(url)) {
            iv.setImageResource(R.mipmap.carlogo)
        } else {
            Picasso.get()
                .load(url)
                .placeholder(R.mipmap.carlogo)
                .error(R.mipmap.carlogo)
                .into(iv)
        }
    }
}